package hadoop.mr02;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

import java.util.HashMap;

public class student extends Partitioner<Text, Text> {
    private static HashMap<String,Integer> status = new HashMap<>();
    static {
        status.put("1",0);
        status.put("2",1);
    }
    // 重写分区方法
    @Override
    public int getPartition(Text key, Text value, int i) {
        Integer code = status.get(key.toString());
        if(code != null){
            return code;
        }
        return 3; // 没有性别的分区
    }
}
